<%@LANGUAGE="VBSCRIPT"%>
 
<!--#include file="functions.asp" -->
<%
dim TheDate
TheDate = String(2-Len(CStr(Month(Date))),"0")& CStr(Month(Date))& "/"& String(2-Len(CStr(Day(Date))),"0")& CStr(Day(Date))& "/"&Year(Date)
Date2 = DateAdd("d",30, Date)
TheDate2 = String(2-Len(CStr(Month(Date2))),"0")& CStr(Month(Date2))& "/"& String(2-Len(CStr(Day(Date2))),"0")& CStr(Day(Date2))& "/"&Year(Date2)


%>
<%
set CompCode = Server.CreateObject("ADODB.Recordset")
CompCode.ActiveConnection = cn
CompCode.Source = "SELECT * FROM dbo.COMPCODE"
'CompCode.CursorType = 0
'CompCode.CursorLocation = 2
'CompCode.LockType = 3
CompCode.Open()
CompCode_numRows = 0
%>

<SCRIPT TYPE="text/JavaScript" SRC="Common.js"></SCRIPT>

<SCRIPT Language="JavaScript">
var InvStatus='<%= request.querystring("InvStatus") %>';
var dsort='<%= request.querystring("dsort") %>';
var dorder='<%= request.querystring("dorder") %>';
var Location='<%= request.querystring("Location") %>';
var UserCoord='<%= request.querystring("UserCoord") %>';
var RefOrder='<%= request.querystring("refOrder") %>';
var VendorID='<%= request.querystring("VendorID") %>';
var CurSymbol='<%= request.querystring("CurSymbol") %>';
var RecDate='<%= request.querystring("RecDate") %>';
var RecDate2='<%= request.querystring("RecDate2") %>';
var RptCond='<%= request.querystring("RptCond") %>';

function DocLoad(){
document.form1.reqInvoiceNo.focus();
}

// This function removes non-numeric characters
function stripNonNumeric( str )
{
  str += '';
  var rgx = /^\d|\.|-$/;
  var out = '';
  for( var i = 0; i < str.length; i++ )
  {
    if( rgx.test( str.charAt(i) ) ){
      if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) ||
             ( str.charAt(i) == '-' && out.length != 0 ) ) ){
        out += str.charAt(i);
      }
    }
  }
  return out;
}

function CheckSANData(which){
	var isValid = false;
	isValid = checkrequired(which);

	if(isValid){
		isValid = false;
		var submittedAmount = parseFloat(stripNonNumeric(document.form1.reqInvoiceAmount.value));		
		var remainingAmount = parseFloat(stripNonNumeric(document.form1.RemainingAmount.value));
		isValid = (submittedAmount < remainingAmount);
		if(!isValid){
			alert("Submitted Amount must be less than Remaining Amount.");
		}
	}
	
	return isValid;
}

function CheckVendor(y)
{ if (y!="") {
window.open("ValVendor.asp?vendID="+y+"&src=document.form1.reqVendorID&fld=document.form1.VendorName","","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else document.form1.VendorName.value="";
}

function CheckPO(y,z)
{ if (y!="") {
window.open("ValPO.asp?PONUM="+y+"&src=document.form1.reqPONum&fld="+z,"","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else document.form1.reqPONum.value="";
}

function CheckCurr(y)
{ if (y!="") {
window.open("ValCurr.asp?CurrID="+y+"&src=document.form1.reqCurrency&fld=document.form1.exRate&fld2=document.form1.CurSymbol2","","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else 
{
document.form1.exRate.value="";
document.form1.CurSymbol2.value="";}
}

function CheckWHT(y)
{ if (y!="") {
window.open("ValWHT.asp?WHTID="+y+"&src=document.form1.WHTName&fld=document.form1.WHTRate","","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else document.form1.WHTRate.value="";
}

function redirect(which){
location='Inv_Detail.asp?seqnum='+which+'&InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}
function redirect2(){
location='InvList.asp?InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}

</SCRIPT>
<!-- #include file="pagetop.asp" -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td nowrap height="21" bgcolor="#FFFFFF" width="3%" background="images/menu_end.gif">&nbsp;</td>
    <td nowrap height="21" bgcolor="#FFFFFF" width="28"> 
      <div align="center"><img src="images/menu_awal_off.gif" width="28" height="33"></div>
    </td>
    <td width="10%" background="images/menuoff.gif" height="21" nowrap> 
      <div align="center"><b><a href="#" class="menu" onClick="return redirect2()">Service Acceptance 
        List</a></b></div>
    </td>
    <td width="28" height="21" nowrap><img src="images/menu_off_on_separator.gif" width="28" height="33"></td>
    <td width="10%" background="images/menuon.gif" height="21" nowrap> 
      <div align="center"><b class="menu">Register Service Acceptance</b></div>
    </td>
    <td height="21" bgcolor="#FFFFFF" width="11"><img src="images/Menu_onend.gif" width="13" height="33"></td>
    <td height="21" bgcolor="#FFFFFF" background="images/menu_end.gif"> 
      <div align="right"></div>
    </td>
  </tr>
  <tr bgcolor="#93bee2"> 
    <td height="21" width="3%" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="10%" height="21" bgcolor="#93bee2">&nbsp;</td>
    <td width="28" height="21">&nbsp;</td>
    <td width="10%" height="21">&nbsp;</td>
    <td height="21">&nbsp;</td>
    <td height="21">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#93bee2">
  <tr> 
    <td width="4%" height="12">&nbsp;</td>
    <td width="2%" height="12">&nbsp;</td>
    <td height="12">&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF"><img src="images/curv_data.gif" width="21" height="21"></td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"> 
      <form name="form1" method="post" action="Inv_Process.asp" onSubmit="return CheckSANData(this)">
        <table width="100%" border="0" cellspacing="2" cellpadding="3">
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Vendor Doc No.:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="reqInvoiceNo" size="20" maxlength="20" class="InputBox">
              <input type="hidden" name="seqnum2" value="0">            </td>
            <td width="15%"> 
              <div align="right"></div>            </td>
            <td width="2%">&nbsp;</td>
            <td>&nbsp; </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Vendor ID:</b></div>
			</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="reqVendorID" size="10" maxlength="10" class="InputBox" onBlur="CheckVendor(this.value);">
              <input type="button" name="Button22" value=" ... " class="sbttn" onClick="openpopup('VendorList.asp?fName=form1.reqVendorID&fName2=form1.VendorName&fName3=form1.reqBranch')" >            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Vendor Branch:</b> </div>            </td>
            <td width="2%">&nbsp;</td>
            <td bgcolor="#FFFFFF">
              <input type="text" name="reqBranch" class="InputBox" size="20" maxlength="20">            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Vendor Name:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4" valign="middle"> 
              <input type="text" name="VendorName" size="50" class="InputBox">
              &nbsp;<b>&nbsp;</b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede">
              <div align="right"><b>Reference Order:&nbsp;</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <script language="JavaScript">
				function setPO(which){
				if (which.value=="Y"){
					document.form1.reqPONum.readOnly=false;
					document.form1.reqPONum.style.background='#ffffff';
					document.form1.reqPONum.value='';
					document.form1.btnPO.disabled=false;}
				else {
					document.form1.reqPONum.style.background='#cccccc';
					document.form1.reqPONum.value=' ';
					document.form1.reqPONum.readOnly=true;
					document.form1.btnPO.disabled=true;
					}
				}
				</script>
              <input type="radio" name="RefOrder" value="Y" onClick="setPO(this)" checked="checked">
              YES 
              <input type="radio" name="RefOrder" value="N" onClick="setPO(this)">
              NO 
              <input type="radio" name="RefOrder" value="O" onClick="setPO(this)">
              OTHER </td>
            <td width="15%" bgcolor="#dedede">
              <div align="right"><b>PO/SO/CO Number:&nbsp;</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td>
              <input type="text" name="reqPONum" class="InputBox" size="20" onBlur="CheckPO(this.value,document.form1.reqVendorID.value);"> 
              <input type="button" name="btnPO" value=" ... " class="sbttn" onClick="OpenContractList()" >
              <input type="hidden" name="VendorPO">            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Received Date:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="ReceivedDate" size="12" maxlength="12" class="InputBox" value="<%= TheDate %>" onBlur="AddDate(this.value);document.form1.DueDate.focus();" onChange="AddDate(this.value)">
              <input type="button" name="Submit5" value=" ... " class="sbttn" onClick="javascript:show_calendar('form1.ReceivedDate');" onBlur="AddDate(document.form1.ReceivedDate.value)">
              <script language="JavaScript">
function AddDate(x)
{
var CurDate=new Date(x);
var ms=CurDate.getTime()+30*86400000;
var newDate=new Date(ms) ;
document.form1.DueDate.value = new String((newDate.getMonth()+1)+'/'+newDate.getDate()+'/'+newDate.getYear());
//document.form1.DueDate.value = String(CurDate);
}
</script>            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Due Date:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <input type="text" name="DueDate" size="12" maxlength="12" class="InputBox" value="<%= TheDate2 %>" onBlur="document.form1.reqReceivedBy.focus();">
              <input type="button" name="Submit52" value=" ... " class="sbttn" onClick="javascript:show_calendar('form1.DueDate')">            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Received By:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="reqReceivedBy" size="10" maxlength="10" class="InputBox" onBlur="CheckEmp(this.value, 'form1.empName',form1.empName);" value="<%= empCode %>">
              <input type="button" name="Button223" value=" ... " class="sbttn" onClick="OpenEmpList(form1.reqReceivedBy.value, 'form1.reqReceivedBy', 'form1.empName')" >            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Department:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <input type="text" name="Dept" size="30" maxlength="30" class="InputBox" value="<%= Dept %>">            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="empName" size="30" class="InputBox" value="<%= usrFullName %>">            </td>
			<td width="15%" bgcolor="#dedede"> 
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
			
			</td>
            
          </tr>
		  
		  <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>User Coordinator:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="reqUserCoord" size="10" maxlength="10" class="InputBox" onBlur="CheckEmp(this.value, 'form1.UserCoordName',form1.UserCoordName);">
              <input type="button" name="Button223" value=" ... " class="sbttn" onClick="OpenEmpList(form1.reqUserCoord.value, 'form1.reqUserCoord', 'form1.UserCoordName')" >            
			</td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>User Dept:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td> 
				<input type="text" name="reqUserDept" size="10" maxlength="10" class="InputBox" onBlur="CheckEmp(this.value, 'form1.UserDeptName', form1.UserDeptName);" >
              <input type="button" name="Button223" value=" ... " class="sbttn" onClick="OpenEmpList(form1.reqUserDept.value, 'form1.reqUserDept', 'form1.UserDeptName')" >  
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
                <input type="text" name="UserCoordName" size="30" maxlength="30" class="InputBox">         
			</td>
			<td width="15%" bgcolor="#dedede"> 
            
			</td>
            <td width="2%">&nbsp;</td>
            <td> 
				<input type="text" name="UserDeptName" size="30" class="InputBox"> 
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Currency:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="reqCurrency" size="15" maxlength="15" class="InputBox" onBlur="CheckCurr(this.value)">
              <input type="button" name="Button222" value=" ... " class="sbttn" onClick="openpopup2('CurencyList.asp?fName=form1.reqCurrency&fName2=form1.exRate&fName3=form1.CurSymbol2')" >
              <input type="hidden" name="CurSymbol2">            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Exchange Rate:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <input type="text" name="exRate" size="15" class="InputBox">            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Invoice Amount:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="reqInvoiceAmount" size="20" maxlength="20" class="NumBox" onBlur="th_sep(this);">            
			</td>
            <td width="15%" bgcolor="#dedede">
				<div align="right"><b>Remaining Amount:</b></div> 
			</td>
            <td width="2%">&nbsp;</td>
            <td>
				<input type="text" name="RemainingAmount" size="20" maxlength="20" class="NumBox" onBlur="th_sep(this);">
			</td>
          </tr>
          <tr>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Description:</b></div>            
			</td>
            <td width="2%">&nbsp;</td>
            <td height="18" colspan="4">
				<textarea name="reqDescription" cols="60" rows="3" class="InputBox"></textarea>
			</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF" height="18"> 
              <div align="right"><b></b></div>            </td>
            <td width="2%" height="18">&nbsp;</td>
            <td width="30%" height="18">&nbsp;</td>
            <td width="15%" bgcolor="#FFFFFF" height="18">&nbsp;</td>
            <td width="2%" height="18">&nbsp;</td>
            <td height="18">&nbsp;</td>
          </tr>
		  <!--
		  
          <tr> 
            <td width="15%" bgcolor="#FFFFFF"> 
              <div align="right"><b></b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="checkbox" name="cbVAT" value="Y">
              VAT Paid To Vendor</td>
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b><b><b><b>WHT Name:</b></b></b></b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="WHTName" size="15" maxlength="15" class="InputBox" onBlur="CheckWHT(this.value);calcWHT(document.form1.WHTRate.value,document.form1.reqInvoiceAmount.value)">
              <input type="button" name="Button2232" value=" ... " class="sbttn" onClick="openpopup('WHTList.asp?fName=form1.WHTName&fName2=form1.WHTRate')" onBlur="calcWHT(document.form1.WHTRate.value,document.form1.reqInvoiceAmount.value)">
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b><b>WHT Rate:</b></b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <input type="text" name="WHTRate" size="6" maxlength="6" class="NumBox" onBlur="calcWHT(this.value,document.form1.reqInvoiceAmount.value)">
              <script language="JavaScript">
function calcWHT(x,y){
var re=/\,/g;//untuk mereplace koma
//var dVal=Number(dField.value.replace(re,""));
  var WHTRate = Number(x.replace(re,""));
  var InvAmt = Number(y.replace(re,""));
  var WHTAmt = 0;
  WHTAmt = InvAmt * WHTRate/100;
  document.form1.WHTAmt.value=WHTAmt.withCommas();
}
</script>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>VAT Rate:</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="text" name="VATRate" class="NumBox" size="6" maxlength="6" value="10">
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>WHT Amount:</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <input type="text" name="WHTAmt" size="15" maxlength="15" class="NumBox">
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="checkbox" name="cbOri" value="Y">
              Original Invoice with Revenue Stamp</td>
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td> 
              <input type="checkbox" name="cbTax" value="Y">
              Tax Invoices (6 pages)</td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%">&nbsp;</td>
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
		  
		  -->
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Action:</b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <input type="submit" name="Submit" value="    Save    " class="sbttn">
              <input type="button" name="Submit2" value="  Cancel  " class="sbttn">            </td>
            <td width="15%" bgcolor="#FFFFFF"> 
              <div align="right"><b></b></div>            </td>
            <td width="2%">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
CompCode.Close()
%>
